import request from "@/utils/request.js";
import { useUserStore } from "@/stores/user.js";
// const userStore = useUserStore();
// 注册
export const loginApi = (user) => {
  return request({
    method: "get",
    url: "/api/login?user=" + user,
  });
};
export const menuApi = (user) => {
  return request({
    method: "get",
    url: "/api/permission?user=" + user,
  });
};

/**
 * 动态添加路由
 */
// export async function addDynamicRoutes() {
//   try {
//     // 获取后端返回的路由信息
//     const backendRoutes = await getRoutesFromBackend();

//     // 比对后端返回的路由信息和本地定义的路由信息
//     const matchedRoutes = filterRoutes(backendRoutes, asyncRoutes);

//     // 将匹配的路由添加到路由数组中
//     const router = createRouter({
//       history: createWebHistory(),
//       routes: constantRoutes.concat(matchedRoutes), // 将静态路由和动态路由合并
//     });

//     return router;
//   } catch (error) {
//     console.error("Failed to add dynamic routes:", error);
//     throw error;
//   }
// }
